import { effectScope, ref } from "vue";
import { piniaSymbol } from "./rootStore";

export function createPinia() {
  const scope = effectScope();
  const state = scope.run(() => ref({}));

  const pinia = {
    install(app) {
      app.provide(piniaSymbol, pinia);
      app.config.globalProperties.$pinia = pinia;
    },
    use() {
      // 注入插件，自定义插件
    },
    state,
    _e: scope,
    _s: new Map(),
  };
  return pinia;
}
